package com.haiyi.software.tools;

import com.haiyi.software.app.MainApplication;
import com.haiyi.software.entity.BeanLoginResultBody;
import com.haiyi.software.entity.UserInfo;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;

public class MyDBHelper extends SQLiteOpenHelper {

	private static final int dbVerson = 6;

	public MyDBHelper(String dbname) {

		super(MainApplication.getInstance().getApplicationContext(), dbname,
				null, dbVerson);

		// TODO 自动生成的构造函数存根
	}

	public MyDBHelper getMyDBHelper() {

		String dbName = "db_"
				+ MainApplication.getInstance().getMineUserInfo().getUid()
				+ ".db";

		return new MyDBHelper(dbName);
	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		// TODO 自动生成的方法存根

		db.execSQL("create table if not exists tb_message(id INTEGER PRIMARY KEY AUTOINCREMENT,hi_id text,name text,body text,times text,state text,read_state text default 1,download text default 0,siID text,uhead text)");

		Log.i("create", db.getPath());
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		// TODO 自动生成的方法存根
		// db.execSQL("ALTER TABLE tb_message ADD uhead text");
		db.execSQL("DROP TABLE IF EXISTS tb_message");
		onCreate(db);
		Log.i("update", db.getPath());

	}

}
